home *** CD-ROM | disk | FTP | other *** search
/ PC-Blue - MS DOS Public Domain Library / PC-Blue MS-DOS Public Domain Library - NYACC.iso / vol129 / xlisp.c < prev    next >
Encoding:
C/C++ Source or Header  |  1986-12-15  |  1.9 KB  |  88 lines

  1. /* xlisp - an experimental version of lisp that supports object-oriented
  2.            programming */
  3.  
  4. #include "xlisp.h"
  5.  
  6. /* define the banner line string */
  7. #define BANNER    "XLISP version 1.4a, Copyright 1985, by David Betz"
  8.  
  9. /* external variables */
  10. extern NODE *s_stdin,*s_stdout;
  11. extern NODE *s_evalhook,*s_applyhook;
  12. extern NODE *true;
  13.  
  14. /* main - the main routine */
  15. main(argc,argv)
  16.   int argc; char *argv[];
  17. {
  18.     NODE expr;
  19.     CONTEXT cntxt;
  20.     int i;
  21.  
  22.     /* print the banner line */
  23. #ifdef MEGAMAX
  24.     _autowin(BANNER);
  25. #else
  26.     printf("%s\n",BANNER);
  27. #endif
  28.  
  29.     /* setup initialization error handler */
  30.     xlbegin(&cntxt,CF_ERROR,(NODE *) 1);
  31.     if (setjmp(cntxt.c_jmpbuf)) {
  32.     printf("fatal initialization error\n");
  33.     exit();
  34.     }
  35.  
  36.     /* initialize xlisp */
  37.     xlinit();
  38.     xlend(&cntxt);
  39.  
  40.     /* reset the error handler */
  41.     xlbegin(&cntxt,CF_ERROR,true);
  42.  
  43.     /* load "init.lsp" */
  44.     if (setjmp(cntxt.c_jmpbuf) == 0)
  45.     xlload("init",FALSE,FALSE);
  46.  
  47.     /* load any files mentioned on the command line */
  48. #ifndef MEGAMAX
  49.     if (setjmp(cntxt.c_jmpbuf) == 0)
  50.     for (i = 1; i < argc; i++)
  51.         if (!xlload(argv[i],TRUE,FALSE))
  52.         xlfail("can't load file");
  53. #endif
  54.  
  55.     /* create a new stack frame */
  56.     xlsave(&expr,NULL);
  57.  
  58.     /* main command processing loop */
  59.     while (TRUE) {
  60.  
  61.     /* setup the error return */
  62.     if (setjmp(cntxt.c_jmpbuf)) {
  63.         s_evalhook->n_symvalue = NIL;
  64.         s_applyhook->n_symvalue = NIL;
  65.         xlflush();
  66.     }
  67.  
  68.     /* read an expression */
  69.     if (!xlread(s_stdin->n_symvalue,&expr.n_ptr))
  70.         break;
  71.  
  72.     /* evaluate the expression */
  73.     expr.n_ptr = xleval(expr.n_ptr);
  74.  
  75.     /* print it */
  76.     stdprint(expr.n_ptr);
  77.     }
  78.     xlend(&cntxt);
  79. }
  80.  
  81. /* stdprint - print to standard output */
  82. stdprint(expr)
  83.   NODE *expr;
  84. {
  85.     xlprint(s_stdout->n_symvalue,expr,TRUE);
  86.     xlterpri(s_stdout->n_symvalue);
  87. }
  88.